package com.ms.p2p.provider;


import com.ms.common.exception.NoticeException;
import com.ms.p2p.bean.PageBean;
import com.ms.p2p.entity.loan.Loan;
import com.ms.p2p.entity.loan.LoanImg;
import com.ms.p2p.entity.loan.LoanTenderRecord;
import com.ms.p2p.entity.member.Member;
import com.ms.p2p.entity.system.AdminUser;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;


public interface LoanProvider{


    public void successLoan(Loan borrow, List<LoanTenderRecord> borrowTenderList, String ip);

    /***
     * 发放奖励
     **/

    public void awardForTender(Loan loan, List<LoanTenderRecord> tenderList, String ip);


    public int overBorrow(Loan borrow) ;
    /**
     * 投标核心方法
     **/

    public int tender(BigDecimal successAmount, Integer id);


    public int insert(Loan map);


    public List<Map<String, Object>> findPager(String borrowId, String userName, Integer userId, Integer borrowType,
                                               Integer borrowStatus, Integer timeLimitBegin, Integer timeLimitEnd,
                                               Integer aprBegin, Integer aprEnd, Integer lowestAccountBegin,
                                               Integer lowestAccountEnd, Integer borrowStyle, String begin_time,
                                               String end_time, PageBean borrowPage) ;

    public Integer findCount(String borrowId, String userName, Integer userId, Integer borrowType,
                             Integer borrowStatus, Integer timeLimitBegin, Integer timeLimitEnd,
                             Integer aprBegin, Integer aprEnd, Integer lowestAccountBegin,
                             Integer lowestAccountEnd, Integer borrowStyle, String begin_time,
                             String end_time) ;

    /**
     * 根据ID查询borrow信息
     *
     * @param id
     * @return
     */
    public Loan findById(String id);
    /**
     * 修改标的信息
     *
     * @param map
     * @return
     */
    public int update(Loan map) ;


    public Integer count(String userId,String status);
    /**
     * 修改标的信息
     *
     * @param map
     * @return
     */

    public int updateOptimistic(Loan map) ;
    /**
     * 插入图片
     *
     * @param map
     * @return
     */

    public int insertImg(LoanImg map);

    /**
     * 查询某个标的所有图片
     *
     * @return
     */
    public List<LoanImg> findImgByBorrowId(Integer borrow_id);

    /**
     * 删除某个标下的所有图片
     *
     * @return
     */

    public int delImgByBorrowId(Integer borrow_id);

    /**
     * 撤销招标，解冻投资人的投资金额
     */

    public void calculateFailBid(String ip, Loan borrow);

    /**
     * 累计交易额
     */
    public Map<String, Object> totalMoney();


    /**
     * 生成待还表记录
     */

    public void addStay(Loan loan,String ip);
    /**
     * 生成待收表记录
     *
     * @param loan
     * @return
     */

    public void addDueRecord(Loan loan,String ip);

    public Loan findCommend();



    public void doTender(BigDecimal successAmount, Loan borrow, Member user, double account, String remoteIp, String packet_id)throws  NoticeException;

    public void verify(Loan loan, String status, AdminUser emp, String remark, String ip)throws  NoticeException;

    /**
     * 满标时候撤销
     */

    public void full_cancel(Loan borrow, AdminUser user, String ip) throws  NoticeException;

    /**
     * 满标时候撤销
     */

    public void loan_cancel(Loan borrow, AdminUser user, String ip) throws  NoticeException;



    Loan findRookie();
}
